<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*" %>
<%
	session.setAttribute("stage", "1");
	//リクエスト文字列のエンコードを設定
	request.setCharacterEncoding("UTF-8");
 	// エラーの取得
 	Integer nullCnt = (Integer)request.getAttribute("nullCnt");
	Map<String, String> errors = (Map<String, String>)request.getAttribute("errors");
	//パラメータの取得
	String name = (String)request.getAttribute("name");
	String nameErr = "";
	if(name == null) {
		name = "";
	} else if("".equals(name)) {
		nameErr = " class=\"red_frame\"";
	}
	String ruby = (String)request.getAttribute("ruby");
	String rubyErr = "";
	if(ruby == null) {
		ruby = "";
	} else if("".equals(ruby) || errors.containsKey("ruby")) {
		rubyErr = " class=\"red_frame\"";
	}
	String level = (String)request.getAttribute("level");
	String checked = null;
 	if("true".equals(level)) { checked = "checked=\"checked\""; }
 	String password = (String)request.getAttribute("password");
 	String passErr = "";
	if(password == null) {
		password = "";
	} else if("".equals(password) || errors.containsKey("password")) {
		password = "";
		passErr = " class=\"red_frame\"";
	}
%>
<jsp:include page="/share/layout.jsp">
    <jsp:param name="title" value="新規担当者登録"/>
    <jsp:param name="css" value="manager.css"/>
    <jsp:param name="content">
        <jsp:attribute name="value">
<!-- contents start -->
<% if(nullCnt != null || errors != null) { %>
		<div id="msg_area" class="error">
			<% if(nullCnt > 0) { %>未入力の項目があります<br /><% } %>
			<% if(errors.containsKey("ruby")) { %><%= errors.get("ruby") %><% } %>
			<% if(errors.containsKey("password")) { %><%= errors.get("password") %><% } %>
		</div>
<% } %>

<p>新規担当者情報を入力してください</p>

<form id="mng_form" action="EntryServlet" method="post">
	<table id="mng_table" class="form_table">
		<tr>
			<th>担当者名<br />(例：山田太郎)</th>
			<td><input type="text" name="name" size="20"<%= nameErr %> value="<%= name %>" /></td>
		</tr>
		<tr>
			<th>フリガナ<br />(例：ヤマダタロウ)</th>
			<td><input type="text" name="ruby" size="20"<%= rubyErr %> value="<%= ruby %>" /></td>
		</tr>
		<tr>
			<th>種別</th>
			<td><label><input type="radio" name="level" value="0" checked="checked" /> 担当者</label>
			　<label><input type="radio" name="level" value="1" <%= checked %> /> 上位管理者</label></td>
		</tr>
		<tr>
			<th>パスワード<br />(半角英数字)</th>
			<td><input type="type" name="password" size="15"<%= passErr %> value="<%= password %>" /></td>
		</tr>
	</table>
	<div id="btn_area">
		<input class="button" type="button" value="戻る" onClick="self.history.back()" />
		<input class="button" type="submit" value="確認" />
	</div>
</form>
<!-- contents end -->
        </jsp:attribute>
    </jsp:param>
</jsp:include>